package json;

import java.util.ArrayList;
import java.util.List;

import org.codehaus.jackson.map.ObjectMapper;

import cn.egame.common.cache.ICacheClient;
import cn.egame.common.cache.SCacheClient;
import cn.egame.common.util.Utils;

import com.pojo.Student;

public class TestJson {
    public static ICacheClient getCache() {
        return SCacheClient.getInstance("open");
    }

    public static void main(String[] args) {
        try {
            Utils.initLog4j();
            ObjectMapper mapper = new ObjectMapper();
            List<Student> list = new ArrayList<Student>();  
            for(int i =0;i<1000;i++){
                
                Student student = new Student(10000, "zhangnsa", "nanjing");
                list.add(student);
            }
            byte[] buffer = mapper.writeValueAsBytes(list);
            System.out.println("@@@" + buffer.toString());
            
            
//            long t = Utils.getCurrentTime();
//            getCache().set("name", buffer);
//            Object object= getCache().get("name");
//            long run_time = Utils.getCurrentTime() - t;
//            System.out.println(run_time);
//            byte[] arr =(byte[]) object;
//            System.out.println(new String(arr));
            
            long t = Utils.getCurrentTime();
            getCache().set("name_object", list);
            List<Student> l =   getCache().getListT(Student.class, "name_object");
            long run_time = Utils.getCurrentTime() - t;
            System.out.println(run_time);
            System.out.println(l.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
